package com.edu.exam.enums.grading;

/**
 * 缓存类型枚举
 */
public enum CacheType {
    QUERY_RESULT("QUERY_RESULT", "查询结果缓存"),
    STATISTICS_DATA("STATISTICS_DATA", "统计数据缓存"),
    CONFIG_DATA("CONFIG_DATA", "配置数据缓存"),
    USER_PERMISSION("USER_PERMISSION", "用户权限缓存"),
    DICTIONARY_DATA("DICTIONARY_DATA", "字典数据缓存"),
    TEMP_DATA("TEMP_DATA", "临时数据缓存");

    private final String code;
    private final String description;

    CacheType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static CacheType fromCode(String code) {
        for (CacheType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return QUERY_RESULT; // 默认返回查询结果缓存
    }
}